package domain

import (
	"github.com/robfig/cron/v3"
	"time"
)

type Job struct {
	Id         int64
	Name       string
	CancelFunc func() error
	Cron       string
	Executor   string
}

func (c Job) NextTime() time.Time {
	parser := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
	parse, _ := parser.Parse(c.Cron)
	next := parse.Next(time.Now())
	return next
}
